nlp_architect.models.bist_parser.BISTModel

class nlp_architect.models.bist_parser.BISTModel(activation='tanh', lstm_layers=2, lstm_dims=125, pos_dims=25)[source]

BIST parser model class. This class handles training, prediction, loading and saving of a BIST parser model. After the model is initialized, it accepts a CoNLL formatted dataset as input, and learns to output dependencies for new input.

Parameters
  • activation (str, optional) – Activation function to use.

  • lstm_layers (int, optional) – Number of LSTM layers to use.

  • lstm_dims (int, optional) – Number of LSTM dimensions to use.

  • pos_dims (int, optional) – Number of part-of-speech embedding dimensions to use.

model

The underlying LSTM model.

Type

MSTParserLSTM

params

Additional parameters and resources for the model.

Type

tuple

options

User model options.

Type

dict

__init__(activation='tanh', lstm_layers=2, lstm_dims=125, pos_dims=25)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([activation, lstm_layers, …])

Initialize self.

fit(dataset[, epochs, dev])

Trains a BIST model on an annotated dataset in CoNLL file format.

load(path)

Loads and initializes a BIST model from file.

predict(dataset[, evaluate])

Runs inference with the BIST model on a dataset in CoNLL file format.

predict_conll(dataset)

Runs inference with the BIST model on a dataset in CoNLL object format.

save(path)

Saves the BIST model to file.

fit(dataset, epochs=10, dev=None)[source]

Trains a BIST model on an annotated dataset in CoNLL file format.

Parameters
  • dataset (str) – Path to input dataset for training, formatted in CoNLL/U format.

  • epochs (int, optional) – Number of learning iterations.

  • dev (str, optional) – Path to development dataset for conducting evaluations.

load(path)[source]

Loads and initializes a BIST model from file.

predict(dataset, evaluate=False)[source]

Runs inference with the BIST model on a dataset in CoNLL file format.

Parameters
  • dataset (str) – Path to input CoNLL file.

  • evaluate (bool, optional) – Write prediction and evaluation files to dataset’s folder.

Returns

The list of input sentences with predicted dependencies attached.

Return type

res (list of list of ConllEntry)

predict_conll(dataset)[source]

Runs inference with the BIST model on a dataset in CoNLL object format.

Parameters

dataset (list of list of ConllEntry) – Input in the form of ConllEntry objects.

Returns

The list of input sentences with predicted dependencies attached.

Return type

res (list of list of ConllEntry)

save(path)[source]

Saves the BIST model to file.